<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript" src="./ajax.js"></script>
    <script type="text/javascript">
        let xhr;
        // 创建xhr
        if(new XMLHttpRequest()){
            xhr = new XMLHttpRequest();
        }else{
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
        // 请求发送 方法 地址 是否异步
        xhr.open("GET","http://localhost:8888/api/getRoutes",true);
        // 设置post请求的请求头 必须要open后send前设置
        // xhr.sheRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        // post请求发送参数形式
        // xhr.send('status=1&flag=1')
        xhr.send();
        // 响应请求
        xhr.onreadystatechange = function(){
            if(xhr.readyState === 4 && xhr.status === 200){
                console.log(xhr.responseText);
            }
        }
    </script>
</body>
</html>